package com.example.homemodule.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.homemodule.view.ui.NewHomeDrugListFragment;
import com.yilijk.base.utils.ListUtil;

import java.util.List;

public class HomeDrugVPAdapter extends FragmentStatePagerAdapter {

    private List<NewHomeDrugListFragment> fragments;

    public HomeDrugVPAdapter(@NonNull FragmentManager fm, int behavior, List<NewHomeDrugListFragment> fragments) {
        super(fm, behavior);
        this.fragments = fragments;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return ListUtil.getSize(fragments);
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return fragments.get(position).getTitle();
    }
}
